import { request, uploadFile } from '@/utils/request';
import { IUserInfo, PageParams } from '@/types/global';

//更新用户信息
export const updateUserInfo = (data: IUserInfo) =>
    request<any>({
        method: 'POST',
        url: '/member/update',
        data
    });

//获取会员等级
export const getMemberLevel = () =>
    request<any>({
        method: 'GET',
        url: '/common/member/level/list'
    });

//获取用户信息
export const memberInfo = () =>
    request<string>({
        method: 'GET',
        url: '/member/info'
    });

//更新用户头像
export const updateAvatar = (data: any) =>
    uploadFile<any>({
        url: '/member/update/avatar',
        filePath: data.filePath,
        name: 'file'
    });

//获取会员收支明细列表
export const getMemberBalanceList = (data: PageParams & { state?: number }) =>
    request<any>({
        method: 'POST',
        url: '/member/balance/log/list',
        data
    });

//新增意见反馈
export const addFeedback = (data: { title: string; content: string }) =>
    request<any>({
        method: 'POST',
        url: '/common/feedback/add',
        data
    });

//获取客服列表
export const getCustomerServiceList = () =>
    request<any>({
        method: 'GET',
        url: '/common/customer/service/list'
    });

//通用码值接口
export const getCommonEnums = () =>
    request<any>({
        method: 'GET',
        url: '/common/enums'
    });

//获取银行卡信息
export const getBankInfo = () =>
    request<any>({
        method: 'GET',
        url: '/bank/info/info '
    });

//添加银行卡信息
export const addBankInfo = (data: { address: string; realName: string; phoneNo: string; network: string }) =>
    request<any>({
        method: 'POST',
        url: '/bank/info/add',
        data
    });

//验证支付密码
export const verifyCashPwd = (data: { cashPwd: string }) =>
    request<any>({
        method: 'POST',
        url: '/member/verify/cash/pwd',
        data
    });

//新增提现
export const addWithdraw = (data: { amount: number; bankId: number; cashPwd: string }) =>
    request<any>({
        method: 'POST',
        url: '/withdraw/add',
        data
    });
